package com.ruoyi.paipan.common;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class SolarYear {
    private int year;
    public static int  MONTH_COUNT = 12;

    public SolarYear(int year) {
        this.year = year;
    }

    @Override
    public String toString()
    {
        return this.year + "";
    }

    public String toFullString()
    {
        return this.year + "年";
    }

    public static SolarYear fromYear(int year)
    {
        return new SolarYear(year);
    }

    public static SolarYear fromDate(Date date)
    {
        return new SolarYear(Solar.fromDate(date).getYear());
    }

    public int getYear()
    {
        return this.year;
    }

    public List<SolarMonth> getMonths()
    {
        List<SolarMonth> l = new ArrayList<>();
        SolarMonth month = SolarMonth.fromYm(this.year, 1);
        l.add(month);
        for (int i = 1; i < SolarYear.MONTH_COUNT; i++) {
            l.add(month.next(i));
        }
        return l;
    }

    public SolarYear next(int years)
    {
        return new SolarYear(this.year + years);
    }

    public static void main(String[] args) {
        System.out.println(SolarYear.fromDate(new Date()));
    }
}
